package woa.sort;

import java.util.Arrays;

/**
 * 选择排序
 *
 * @author wangpeng
 * @date 2022/1/10
 */
public class SelectSort {

    public static void main(String[] args) {
        int[] arr = new int[]{4,3,5,6,71};
        int left = 0;
        for (int i = 0; i < arr.length - 1; i++) {
            int min = i;
            for (int j = i; j < arr.length; j++) {
                if (arr[j] < arr[min]) {
                    min = j;
                }
            }
            int temp = arr[left];
            arr[left] = arr[min];
            arr[min] = temp;
            left++;
        }

        System.out.println(Arrays.toString(arr));
    }
}
